<extend name="Public:mainbase" />
<block name="content">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/dhtmlxtree.css"/>
<script language="javascript" src="__PUBLIC__/js/member.js?{:time()}"></script>  
<script language="javascript" src="__PUBLIC__/js/Validform_v5.3.2_min.js?{:time()}"></script> 
<style type="text/css">
	.Validform_checktip{line-height: 34px}
</style> 
<!--  内容列表   -->
<form name="form2" method="post">
<table width="98%" class="table table-bordered  table-hover table-condensed "  align="center">
<tr bgcolor="#E7E7E7" >
	<td height="28" colspan="11" background="__PUBLIC__/images/tbg.gif" style="padding-left:10px;">
	◆ 文稿列表 &nbsp;&nbsp;&nbsp;&nbsp;<!--<button type="button" class="btn btn-xs btn-warning" data-toggle="modal" data-target=".newarticlebox"><i class="glyphicon glyphicon-plus"></i> 添加文稿</button>-->
	</td>
</tr>
<tr align="center" bgcolor="#FBFCE2" height="25">
	<td width="6%">ID</td>
	<td width="4%">选择</td>
	<td width="10%">文稿标题</td>
	<td width="10%">文稿内容</td>
	<td width="10%">发布人</td>
	<td width="10%">联合记者</td>
	<td width="10%">创建时间</td>
	<td width="10%">状态</td>
	<td width="10%">操作</td>
</tr>
<foreach name="articleList" item="val">
<tr align='center' bgcolor="#FFFFFF" height="26">
	<td nowrap>{$val.id}</td>
	<td>
		<input name="aid" type="checkbox" value="{$val.id}" class="np" />
	</td>
	<td>{$val.title}</td>
	<td>{$val.content|substr=0,20}</td>
	<td>{$val.realname}</td>		
	<td>{$val.author}</td>		
	<td>{$val.create_time|myDate="Y-m-d H:i",###}</td>
	<td>
	<switch name="val.state">
		<case value="-1"><span style='color:#ccc'>草稿</span></case>
		<case value="0"><span style='color:blue'>待审核</span></case>
		<case value="1"><span style='color:green'>审核通过</span></case>
		<case value="2"><span style='color:gray'>审核中</span></case>
		<case value="3"><span style='color:red'>打回</span></case>
		<default />{$val.state}
	</switch>
	</td>
	<td>
		<a href="{:U('Article/editArticle')}?id={$val.id}" class='editarticle'>编辑</a>
		
		<!-- <a href="javascript:;" data-aid='{$val.id}' class='push'>推送</a>
		| -->
		
		<switch name="val.state">
			<case value="-1">
				|
				<a href="{:U('Article/verify')}?id={$val.id}&state=0" class='verify'>重新发布</a>
			</case>
		<case value="0">
			|
			<a href="{:U('Article/verify')}?id={$val.id}&state=1" class='verify'>通过</a>
			|
			<a href="{:U('Article/verify')}?id={$val.id}&state=3" class='verify'>打回</a>
		</case>
		<case value="1">
			|
			<a href="{:U('Article/verify')}?id={$val.id}&state=3" class='verify'>打回</a>
		</case>
		<case value="2">
			|
			<a href="{:U('Article/verify')}?id={$val.id}&state=1" class='verify'>通过</a>
			|
			<a href="{:U('Article/verify')}?id={$val.id}&state=3" class='verify'>打回</a>
		</case>
		<case value="3">
			|
			<a href="{:U('Article/verify')}?id={$val.id}&state=0" class='verify'>重新发布</a>
		</case>
	</switch>

		|	

		<a href="javascript:;" data-aid='{$val.id}' class='delarticle'>删除</a>
	</td>
</tr>
</foreach>
<tr bgcolor="#ffffff">
<td height="36" colspan="11">
	&nbsp;
	<a href="javascript:selAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-ok'></i> 全选</a>
	<a href="javascript:noSelAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-remove'></i> 取消</a>
	<!-- <a href="javascript:checkArc(0)" class="btn btn-xs btn-info">&nbsp;审核&nbsp;</a> -->
	<a href="javascript:;" id="deluserall" class="btn btn-xs btn-info"><i class="glyphicon glyphicon-trash"></i> 删除</a>
</td>
</tr>
</form>
<tr align="right" bgcolor="#F9FCEF">
	<td height="36" colspan="11" align="center">
		<div class='page'>{$showpage}</div>
	</td>
</tr>
</table>

<!--  搜索表单  -->
<form name='form3' action='' method='get'>
<input type='hidden' name='dopost' value='listArchives' />
<table width='98%'  class='table' align="center" style="margin-top:8px">
  <tr bgcolor='#EEF4EA'>
    <td background='__PUBLIC__/images/wbg.gif' align='center'>
      <table border='0' cellpadding='0' cellspacing='0' height="32">
        <td nowrap>标题：</td>
        <td width='130'>
          	<input type='text' name='title' value='' style='width:120px' />
        </td>
        <td nowrap>用户名：</td>
        <td width='130'>
          	<input type='text' name='username' value='' style='width:120px' />
        </td>
       <td>
          <input name="imageField" type="image" src="__PUBLIC__/images/button_search.gif" width="60" height="22" border="0" class="np" />
       </td>
      </tr>
     </table>
   </td>
  </tr>
</table>
</form>

<script src="__PUBLIC__/js/dhtmlxtree.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/lang/zh-cn/zh-cn.js"></script>
<style type="text/css">
.editarticlebox { z-index: 900 !important; }
.modal-backdrop	{z-index: 800 !important; }
</style>
<script type="text/javascript">


	 var ue = UE.getEditor('content', {
		toolbars: [
		    ['fullscreen', 'source', 'undo', 'redo'],
		    ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', 'insertimage']
		],
		// imageUrl: '{:U("Article/uploadImage")}',
		// imagePath: '<?= UPLOAD_PATH ?>'
		serverUrl: '{:U("Admin/Article/getImageUploadConfig")}?aid=' + $('.editarticle').data('aid'),
	 });

	$('.delarticle').click(function(){
		if(confirm('是否确定删除此篇文稿？')){
			var obj=this;
			$.get('{:U("ajaxDelArticle")}?id='+$(obj).data('aid'),function(data){
				if(data.status==1){
					$(obj).parents('tr').remove();
				}
			})
		}
	})

	$('#deluserall').click(function(){
		if(confirm('是否确定删除？')){
			var id=$('[name=aid]:checked').map(function(){
				return $(this).val();
			}).get().join()
			
			$.get('{:U("ajaxDelArticle")}?id='+id,function(data){
				if(data.status==1){
					$('[name=aid]:checked').parents('tr').remove();
				}
			})
		}
	})

	$('#newarticlebox').on('show.bs.modal', function (e) {
  		$('#newarticlebox form').get(0).reset();
  		$('#newarticlebox .Validform_checktip').empty().attr('class','Validform_checktip');
  		$('.Validform_error').removeClass('Validform_error');
	})
	$.ajaxSetup({cache:false})
	$('.editarticle').click(function(){
		$('#editarticlebox form').get(0).reset();
		$.get("{:U('ajaxGetArticle')}?aid="+$(this).data('aid'),function(data){
  			if(data!=0){
  				$("#editarticlebox [name=aid]").val(data.id);
  				$("#editarticlebox [name=title]").val(data.title);
  				$("#editarticlebox [name=author]").val(data.author);
  				$("#editarticlebox [name=subtitle]").val(data.subtitle);
  				$("#editarticlebox [name=brief]").val(data.brief);
  				$("#editarticlebox [name=keywords]").val(data.keywords);	
  				var content = data.html_content ? data.html_content : data.content;
  				ue.setContent(content);		
  			}
  		})
  		$('#editarticlebox .Validform_checktip').empty().attr('class','Validform_checktip');
  		$('.Validform_error').removeClass('Validform_error');
		$('#editarticlebox').modal('show');
	})

	$("form").Validform({
		tiptype:2,
		showAllError:true,
		datatype:{
			"zh2-30":/^[\u4E00-\u9FA5\uf900-\ufa2d]{2,30}$/
		},
	})

	function geturl($url){
		$a=$url.split('?');
		return $a[0];
	}

	$('.push').on('click', function () {
		$.get('{:U('Mapi/Article/pushArticle')}?articleId=' + $(this).data('aid'), function (data) {
			if(data.resultCode == 0) {
				alert('推送成功');
			} else {
				alert(data.message);
			}
		});
	});

	function selAll(){
		$('[name=aid]').each(function(){
			this.checked=true;
		})
	}
	function noSelAll(){
		$('[name=aid]').each(function(){
			this.checked=false;
		})
	}


</script>

</block>